package routers

import (
	handler2 "easy-note/gateway/handler"
	"easy-note/gateway/middleware"
	"github.com/cloudwego/hertz/pkg/app/server"
)

func InitRouters(h *server.Hertz) {
	var userHandler handler2.UserHandler
	var noteHandler handler2.NoteHandler
	var jwt = middleware.JWT()
	h.POST("/login", jwt.LoginHandler)
	h.POST("/register", userHandler.Register)
	userRouter := h.Group("/user")
	userRouter.Use(jwt.MiddlewareFunc())
	{
		userRouter.GET("/", userHandler.GetUserByUsername)
	}
	noteRouter := h.Group("/note")
	noteRouter.Use(jwt.MiddlewareFunc())
	{
		noteRouter.GET("/", noteHandler.ListNote)
		noteRouter.GET("/:id", noteHandler.GetNoteById)
		noteRouter.POST("/", noteHandler.CreateNote)
		noteRouter.PUT("/:id", noteHandler.UpdateNote)
		noteRouter.DELETE("/:id", noteHandler.DeleteNote)
	}
}
